package com.msb.sentinelProvider.controller;

import com.msb.common.JsonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/****************************************************
 *
 * @author lbf
 * @date 2025/6/26 14:58
 ****************************************************/
@RestController
public class DataController {

    @Value("${server.port}")
    private String serverPort;

    //模仿数据库存储数据
    public static HashMap<Long,String> hashMap = new HashMap<>();
    static {
        hashMap.put(1l,"鼠标");
        hashMap.put(2l,"键盘");
        hashMap.put(3l,"耳机");
    }

    /**
     * 模拟读取数据
     * @param id
     * @return
     */
    @GetMapping("info/{id}")
    public JsonResult<String> msbSql(@PathVariable("id") Long id){
        System.out.println(" +++++++++++++++++++++++++++++++++++ this is in sentinel provider 9003 +++++++++++++++++++++++++++");

        JsonResult<String> result = new JsonResult(200,hashMap.get(id));


        return result;
    }
}
